use crate::{core::{cluster::CLUSTERS, config::TOKEN}, warn};

macro_rules! unknown_command {
	($command: expr) => {
		warn!(format!("Unknown command: {}", $command));
	};
}

pub fn process_command(commands: Vec<String>) {
	match commands[0].as_str() {
		"show" => { command_show(commands.get(1..commands.len()).unwrap())}
		_ => { unknown_command!(commands[0]); }
	}
}

fn command_show(commands: &[String]) {
	match commands[0].as_str() {
		"config" => {
			println!("TOKEN = {}", TOKEN.lock().unwrap());
			println!("Cluster list:");
			for (_, cluster) in CLUSTERS.lock().unwrap().iter() {
				println!("{:?}", cluster);
			}
		}
		_ => { unknown_command!(commands[0]); }
	}
}
